package org.example.partition;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class PartitionDemo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);
        DataStreamSource<String> source = env.socketTextStream("localhost", 9999);
        //随机分区
        //source.shuffle().print();
        //轮询
        //source.rebalance().print();
        //局部轮
        //source.rescale().print();
        //广播
        //source.broadcast().print();
        source.global().print();
        env.execute("PartitionDemo");
    }
}
